const { gameDetectProcessor } = require("./processor/game-detect-processor")
const { matchClickProcessor } = require("./processor/match-click-processor")
const { switchCharacterProcessor } = require("./processor/switch-character-pocessor")

const { createGameDetectTask } = require("./task/game-detect-task")
const { createBlackScreenDetectTask } = require("./task//black-screen-detect-task")
const { createMatchTemplateTask } = require("./task/template-match-task")
exports.acquireProcessor = function(type) {
    if (type == "game-detect" || type == "black-screen-detect") {
        return gameDetectProcessor
    }
    if (type == "match-click") {
        return matchClickProcessor
    }
    if (type == "switch-character") {
        return switchCharacterProcessor
    }
    return undefined
}

exports.createTask = function(config, scheduler) {
    let callback = (type, result) => scheduler.dispatch(type, result)
    if (config.type == "game-detect") {
        return createGameDetectTask(config, callback)
    }
    if (config.type == "black-screen-detect") {
        return createBlackScreenDetectTask(config, callback)
    }
    if (config.type == "match-click") {
        return createMatchTemplateTask(config, callback)
    }
    if (config.type == "switch-character") {
        return createMatchTemplateTask(config, callback)
    }
    return undefined
}